package cn.yunyichina.utils.dozer;

import org.dozer.DozerBeanMapper;

/**
 * Created by Lullaby on 2017/3/8.
 */
public class Dozer {

    public static <T> T convert(Object source, Class<T> clazz) {
        if (source == null) return null;
        return DozerMapperInstance.INSTANCE.getInstance().map(source, clazz);
    }

    public static void copy(Object source, Object target) {
        if (source == null) return;
        DozerMapperInstance.INSTANCE.getInstance().map(source, target);
    }

}

enum DozerMapperInstance {

    INSTANCE;

    private DozerBeanMapper mapper;

    DozerMapperInstance() {
        mapper = new DozerBeanMapper();
    }

    public DozerBeanMapper getInstance() {
        return mapper;
    }

}
